package com.moarea.app.controller.system.login;

import com.moarea.app.lang.model.ResultObject;
import com.moarea.app.service.inter.login.IIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * 首页信息获取控制
 * <p>
 * jizhong
 * <p>
 * 2017-10-26
 */
@Controller
@RequestMapping(value = "/IndexController")
public class IndexController {

    @Autowired
    private IIndexService indexService;

    /**
     * 获取当前登录用户的信息
     *
     * @param session HttpSession
     * @return ResultObject
     */
    @ResponseBody
    @RequestMapping(value = "/obtainLoginUser", method = RequestMethod.POST, headers = {"Accept=application/json"})
    public ResultObject obtainLoginUser(HttpSession session) {
        return indexService.obtainLoginUser(session);
    }

    /**
     * 用户权限内菜单获取
     *
     * @param param    前端登录参数
     * @param request  HttpServletRequest
     * @param response HttpServletResponse
     * @param session  HttpSession
     * @return 登录结果
     */
    @ResponseBody
    @RequestMapping(value = "/obtainUserMenus", method = RequestMethod.POST, headers = {"Accept=application/json"})
    public ResultObject obtainUserMenus(@RequestBody Map<String, Object> param, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        return indexService.obtainUserMenus(param,request,response,session);
    }



}
